<?php

namespace app\index\controller;

use app\common\CommonController;
use app\index\service\ImportexportService;
use app\index\service\OldproductmanageService;

class Oldproductmanage extends CommonController
{
    public function __construct(){
        parent::__construct();
    }

    /**
     * 老品分派列表
     * @author LSH
     * @return json
     */
    public function getOldProductAssignList(){
        $data = OldproductmanageService::getOldProductAssignList($this->param);
        exitJson($data);
    }

    /**
     * 老品分派列表
     * @author LSH
     * @return json
     */
    public function getOldProductAssignListImg(){
        $data = OldproductmanageService::getOldProductAssignList($this->param);
        exitJson($data);
    }

    /**
     * 编辑任务导出
     * @author LSH
     * @return json
     */
    public function exportEditTaskList()
    {
        $this->param['actionAsync'] = "\app\index\service\OldproductmanageService::getOldProductAssignList";
        $this->param['type'] = 'edit';
        $this->param['old'] = 1;
        $result = ImportexportService::exportLogic($this->param, 16);
        $result['url']='/#/Queue/index';
        exitJson($result);
    }

    /**
     * 编辑任务导入
     * @author LSH
     * @return array
     */
    public function uploadEditTaskListInfo(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\OldproductmanageService::uploadEditImgTaskListInfo";
        $param['type'] = 'edit';
        $result = ImportexportService::importTask($param, 17,2);
        exitJson($result);
    }

    /**
     * 编辑任务批量确认
     * @author LSH
     * @return array
     */
    public function uploadEditBatchAffirm(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\OldproductmanageService::uploadEditImgBatchAffirm";
        $param['type'] = 'edit';
        $result = ImportexportService::importTask($param, 18,2);
        exitJson($result);
    }

    /**
     * 编辑任务批量取消
     * @author LSH
     * @return array
     */
    public function uploadEditBatchCancel(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\OldproductmanageService::uploadEditImgBatchCancel";
        $param['type'] = 'edit';
        $result = ImportexportService::importTask($param, 19,2);
        exitJson($result);
    }

    /**
     * 图片任务导出
     * @author LSH
     * @return json
     */
    public function exportImgTaskList()
    {
        $this->param['actionAsync'] = "\app\index\service\OldproductmanageService::getOldProductAssignList";
        $this->param['type'] = 'img';
        $this->param['old'] = 1;
        $result = ImportexportService::exportLogic($this->param, 20);
        $result['url']='/#/Queue/index';
        exitJson($result);
    }

    /**
     * 图片任务导入
     * @author LSH
     * @return array
     */
    public function uploadImgTaskListInfo(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\OldproductmanageService::uploadEditImgTaskListInfo";
        $param['type'] = 'img';
        $result = ImportexportService::importTask($param, 21,2);
        exitJson($result);
    }

    /**
     * 图片任务批量确认
     * @author LSH
     * @return array
     */
    public function uploadImgBatchAffirm(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\OldproductmanageService::uploadEditImgBatchAffirm";
        $param['type'] = 'img';
        $result = ImportexportService::importTask($param, 22,2);
        exitJson($result);
    }

    /**
     * 图片任务批量取消
     * @author LSH
     * @return array
     */
    public function uploadImgBatchCancel(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\OldproductmanageService::uploadEditImgBatchCancel";
        $param['type'] = 'img';
        $result = ImportexportService::importTask($param, 23,2);
        exitJson($result);
    }

    /**
     * 编辑/图片任务 确定/取消
     * @author LSH
     * @return array
     */
    public function updateAffirmCancelAudit(){
        $rules = [
            'id' => 'require',
            'sku' => 'require',
            'type' => 'require',
            'status' => 'require'
        ];
        $this->validateData($rules);
        $data = OldproductmanageService::updateAffirmCancelAuditLogic($this->param);
        returnJson($data);
    }

    /**
     * 老品分派
     * @author LSH
     * @return json
     */
    public function updateAssignInfo(){
        $rules = [
            'id' => 'require',
            'type' => 'require',
            'operator' => 'require'
        ];
        $this->validateData($rules);
        if(OldproductmanageService::updateAssignInfoLogic($this->param))
            returnJson();
        else
            returnJson('0','操作失败');
    }
    public function updateAffirmCancelAuditLogicCheck(){
        $rules = [
            'id' => 'require',
            'type' => 'require',
            'status' => 'require'
        ];
        $this->validateData($rules);
       OldproductmanageService::updateAffirmCancelAuditLogicCheck($this->param);
    }
}